//--------------------------------------------------------------------------------------------------------------
// <copyright file="CSPMyProperty.cs" company="Microsoft Corporation" author="David Martos" date="01/02/2008">
//     Copyright (c) Microsoft Corporation.  All rights reserved.
// </copyright>
//--------------------------------------------------------------------------------------------------------------
using System;
using System.Data;
using System.Runtime.InteropServices;
using System.Text;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Serialization;
using System.ComponentModel;

using Microsoft.SharePoint;
using Microsoft.SharePoint.WebControls;
using Microsoft.SharePoint.WebPartPages;

using CSP.LoggingEngine;

namespace CSP.WebParts
{

    /// <summary>
    /// This webpart gets information of the citizen property
    /// </summary>
    [Guid("936341F3-3813-4ba8-95ED-FBE4298135FC")]
    public class CSPMembershipRequest : BaseWebPart
    {
        #region members
        protected string noImageUrl;
        protected string citizenImagesGalleryURL;
        private const string NoImageUrlDefault = "";
        private const string CitizenImagesGalleryURLDefault = "";
        #endregion


        #region properties
        [Personalizable(PersonalizationScope.Shared)]
        [WebBrowsable(true)]
        [ResourcesAttribute("NoImageUrlDisplayName", "CSPWebPartParameterCategory", "NoImageUrlDescription")]
        [DefaultValue(NoImageUrlDefault)]
        public string NoImageUrl
        {
            get { return this.noImageUrl; }
            set { this.noImageUrl = value; }
        }

        [Personalizable(PersonalizationScope.Shared)]
        [WebBrowsable(true)]
        [ResourcesAttribute("CitizenImagesGalleryURLDisplayName", "CSPWebPartParameterCategory", "CitizenImagesGalleryURLDescription")]
        [DefaultValue(CitizenImagesGalleryURLDefault)]
        public string CitizenImagesGalleryURL
        {
            get { return this.citizenImagesGalleryURL; }
            set { this.citizenImagesGalleryURL = value; }
        }
        #endregion

        #region methods
        /// <summary>
        /// Constructor
        /// </summary>
        public CSPMembershipRequest()
        {
            this.ExportMode = WebPartExportMode.All;
        }


        /// <summary>
        /// Fired on page create child control, loads the ASCX file
        /// </summary>
        protected override void CreateChildControls()
        {
            base.CreateChildControls();

            try
            {

                UserControls.CSPMembershipRequestWUC control = (UserControls.CSPMembershipRequestWUC)Page.LoadControl(WebPartConstants.CSPMembershipRequestWUC);
                control.WrapperWebPart = this;
                control.NoImageUrl = this.noImageUrl;
                control.CitizenImagesGalleryURL = this.citizenImagesGalleryURL;
                this.Controls.Add(control);

            }
            catch (CSP.Core.CSPException cspex)
            {
                errors.Add(this.LoadResource(WebPartConstants.CSPGenericErrorMessage));
            }
            catch (Exception ex)
            {
                this.LogMessage(this.LoadResource(WebPartConstants.CSPLoadControlErrorMessage), this.GetType().Name, ex);
                errors.Add(this.LoadResource(WebPartConstants.CSPGenericErrorMessage));
            }
        }
        #endregion
    }
}
